package com.nike.thread;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;

import com.nike.dao.NikeDao;

public class NikeLoginPSThread extends Thread {
	private Map<String, Object> zhanghaomap;
	private String ipAndPort;
	
	public NikeLoginPSThread(Map<String, Object> zhanghaomap, String ipAndPort) {
		super();
		this.zhanghaomap = zhanghaomap;
		this.ipAndPort = ipAndPort;
	}

	public Map<String, Object> getZhanghaomap() {
		return zhanghaomap;
	}

	public void setZhanghaomap(Map<String, Object> zhanghaomap) {
		this.zhanghaomap = zhanghaomap;
	}

	public String getIpAndPort() {
		return ipAndPort;
	}

	public void setIpAndPort(String ipAndPort) {
		this.ipAndPort = ipAndPort;
	}

	@Override
	public void run() {
		NikeDao dao = new NikeDao();
		String cmdStr = "java -jar c://nikeloginsingle.jar "+zhanghaomap.get("email")+" "+ipAndPort;
		System.out.println(cmdStr);
		try {
			 zhanghaomap.put("province","CN-34");
			 zhanghaomap.put("city","7970");
			 zhanghaomap.put("area","13663");
			 dao.updateLoginStatus(zhanghaomap);
			Process p = Runtime.getRuntime().exec(cmdStr);
			BufferedInputStream in = new BufferedInputStream(p.getInputStream());
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			String s;
			while ((s = br.readLine()) != null){
				System.out.println(s);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
